> Connecting to Wikipedia... Success! Found 503 tickers. > Initializing download for 505 assets... --- Pipeline Complete: 497 Assets Loaded ---
According to the literature—and cited by Jegadeesh and Titman (1993)—the momentum effect represents perhaps the strongest evidence against the efficient markets hypothesis. The trend-following strategy, a type of momentum strategy, involves conducting a 1-year performance analysis of liquid stocks from developed countries, excluding the last month's performance to remove short-term noise. It then entails buying the top 10 performers and shorting the bottom 10 stocks.
Jegadeesh, N. and Titman, S. (2011). Momentum. SSRN Electronic Journal. doi:https://doi.org/10.2139/ssrn.1919226.
Following this therory, my question is why only the top 10 stock? After all a stock that is 20th in the list may have still have achieved a 80% annual performance and still be a good candidate for momentum trading. Consequently, based on this assumption, I've extended my stock pool to 30 stocks each (long and short candidate list).
============================================================
MOMENTUM SIGNAL GENERATION (DATAFRAME OPTIMIZED)
============================================================
✅ SELECTION COMPLETE.
Longs: 60 assets | Avg Return: 69.50%
Shorts: 60 assets | Avg Return: -34.91%
----------------------------------------
[Top 5 Long Candidates (Strongest Trends)]
Formation_Return
Ticker
WDC 240.34%
STX 200.48%
HOOD 174.91%
MU 161.18%
NEM 158.39%
----------------------------------------
[Top 5 Short Candidates (The 'Worst 5' Performers)]
Formation_Return
Ticker
TTD -70.93%
FISV -69.14%
DECK -54.43%
IT -52.69%
ARE -51.36%
Implementing this strategy is extremely risky, as it exposes the investor to reversal risk and potential high losses. It's important to bear in mind that, as cited by Fan et al. (2012), although momentum strategies exhibit persistent profitability, their returns are volatile and prone to crash risks during specific periods. Therefore, simply selecting the top 10 stocks from these two lists feels too risky, mainly during period of market uncertainty, so I think it would make sense to also value in their last month's performance (21 trading days), which was excluded in the stock pool selection mechanism, to gain a clearer view of short-term performance. This, in my opinion, would increase the chances of picking the most likely winners (to long) and losers (to short).
Fan, M., Kearney, F., Li, Y. and Liu, J., 2022. Momentum and the Cross-section of Stock Volatility. Journal of Economic Dynamics and Control, 144, p.104524.
============================================================
MOMENTUM SIGNAL DIAGNOSTIC (VECTORIZED)
============================================================
> analyzing 120 assets...
✅ DIAGNOSTIC COMPLETE.
EXPLANATION OF THE CHART
The X-Axis: Formation Period Return (The "Signal") This axis answers the question: "Did this stock go up over the last year?"
- What it measures: The long-term trend used to select the stock.
- Time Period: From 1 year ago up to 1 month ago (Days -252 to -21).
Why we stop 1 month ago: In momentum strategies, stocks often experience a "short-term reversal" or "noise" in the most recent month. We intentionally exclude this month from the selection signal to avoid buying stocks that just spiked up on a single news event
The Y-Axis: Holding Period Return (The "Validation") This axis answers the question: "Is the stock STILL going up right now?"
- What it measures: The very recent performance (the last month).
- Time Period: From 1 month ago to Today (Days -21 to 0).
Why we track this: This serves as a diagnostic.
If a stock is a "Winner" (High X-Axis) but is crashing this month (Negative Y-Axis), it might be a "Falling Knife." If a stock is a "Loser" (Low X-Axis) but is rallying this month (Positive Y-Axis), it might be a "Short Squeeze."
==================================================================
ADVANCED FILTER: VECTORIZED REGIME DETECTION
==================================================================
Stats:
Original Longs: 60 -> Verified: 41
Original Shorts: 60 -> Verified: 26
Rejections: 53 (Risky assets removed)
💾 EXPORT SUCCESS: Saved 67 verified candidates to 'momentum_candidates_20260125_1719.csv'
Side Formation_Return Validation_Return
Ticker
WDC Long 2.403356 0.317697
STX Long 2.004788 0.214343
MU Long 1.611831 0.395898
✅ Ready for Portfolio Optimization.
HOW TO USE THIS CHART IN PRACTICE:
Top-Right (Green Zone): X is High: Stock was a winner last year. Y is Positive: Stock is still winning this month. Verdict: Perfect Long Candidate. The trend is intact.
Bottom-Right (Orange Zone - "Momentum Crash"): X is High: Stock was a winner last year. Y is Negative: Stock crashed this month. Verdict: Danger. The trend might be ending.
Bottom-Left (Red Zone): X is Low: Stock was a loser last year. Y is Negative: Stock is still losing this month. Verdict: Perfect Short Candidate. The downtrend is persistent.
Top-Left (Orange Zone - "Short Squeeze Risk") X is Low (Negative): The stock was a Loser last year. It has a strong downtrend signal, which normally makes it a perfect candidate to Short (sell). Y is Positive (High): Despite the long-term crash, the stock has suddenly rallied in the last month.
########################################################################################################
This portfolio put together stocks that are starting to go up (Momentum) that at the same time are fundamentally cheap (Intrinsic value). The strategy is inspired to Eq1 and Eq2 in the journal of finance 68, no. 3 which uses the cross-sectional ranks minus their average to weights securities proportionally in zero-cost portfolios. For the composite score $$Score = (0.5 \times \text{Momentum Rank}) + (0.5 \times \text{Value Rank})$$ I used the eEq3 in the journal of finance 68, no. 3 which gives 50% weight to the security's book-to-market and 50% weight to its momentum score. (Asness et al, 2013) This strategy shoud give insight into a strategy that reduce long-term risks for Value investors. The weights are allocated in the following way: $$\text{Weight} = \frac{\text{Individual Score}}{\text{Total Sum of Scores}}$$
Asness, Clifford S., Tobias J. Moskowitz, and Lasse Heje Pedersen. "Value and momentum everywhere." The journal of finance 68, no. 3 (2013): 929-985.
================================================================================
MULTI-FACTOR SCORING: 50% MOM / 50% VALUE
================================================================================
📊 Candidate Pool: 67 Verified Tickers
📅 Evaluation Period: 2020-01-01 to 2026-01-23
> Fetching Book-to-Market data...
100%|██████████████████████████████████████████████████████████████████████████████████| 67/67 [00:26<00:00, 2.54it/s]
✅ Data Healthy. Running Full Multi-Factor Model. ✂️ Filtering Complete. Final Portfolio: 20 Assets.
[FINAL TRADE LIST PREVIEW]
Side Final_Score Weight
Ticker
GDDY Short 7.46% -7.92%
IT Short 8.21% -7.78%
VRSK Short 18.66% -5.83%
TTD Short 22.39% -5.14%
NOW Short 23.13% -5.00%
DECK Short 31.34% -3.47%
ZTS Short 31.34% -3.47%
LULU Short 34.33% -2.92%
HPQ Short 34.33% -2.92%
ERIE Short 36.57% -2.50%
F Long 70.90% 3.89%
BK Long 72.39% 4.17%
STX Long 74.63% 4.58%
DG Long 75.37% 4.72%
ALB Long 76.12% 4.86%
NEM Long 80.60% 5.69%
HII Long 80.60% 5.69%
INTC Long 84.33% 6.39%
IVZ Long 84.33% 6.39%
CVS Long 85.82% 6.67%
✅ SUCCESS: Portfolio saved to:
📂 Multi-Factor_Model_50_Mom___50_Value_Portfolio_Range_2020-01-01_to_2026-01-23_Created_20260125_1720.csv
============================================================
DATA AUDIT: BOOK-TO-MARKET QUALITY CHECK
============================================================
📊 TOTAL CANDIDATES: 67
✅ SUCCESSFUL FETCH: 63 (94.0%)
❌ FAILED / MISSING: 4 (6.0%)
------------------------------------------------------------
⚠️ MISSING DATA FOR (4):
STX, CAH, HPQ, DVA
💡 NOTE: These stocks were filled with the MEDIAN Book-to-Market
ratio (0.15) to ensure neutral scoring.
------------------------------------------------------------
🔎 OUTLIER DETECTION:
> No extreme Deep Value stocks found.
[HYPER GROWTH / EXPENSIVE] (B/M < 0.05): 9 stocks
GDDY 0.006538
VRSK 0.012397
COR 0.021998
============================================================
--- CONFIGURATION WALK-FORWARD ANALYSIS (ROLLING OPTIMIZATION)---¶
The logic here is designed to be an "Honest Audit" of your core engine. It strips away the complex, potentially biased "Value" data (since we can't accurately get that for the past - not for free) and tests the raw horsepower of your Momentum Strategy over history.
Here is the step-by-step breakdown of exactly how the computer is thinking and executing this simulation.
- The Logic: "The 70/30 Momentum Engine" This strategy believes that stock price moves are not random; they follow a specific physics. It looks for two forces acting together:
Force A: The Deep Trend (70% Weight)
The Math: Return from 12 months ago to 1 month ago (t-12 to t-1).
The Logic: "Is this stock fundamentally winning over the long haul?" This filters out short-term noise and finds stocks with institutional backing.
Force B: The Recent Spark (30% Weight)
The Math: Return from 1 month ago to today (t-1 to t).
The Logic: "Is the trend accelerating?" We don't want a stock that went up last year but has been dead for 30 days. We want active heat.
The Selection Process: Every month, the code looks at the entire market (e.g., 500 stocks) and calculates this Composite Score for every single one.
Buy the 10 strongest
Short the 10 worse
- The Backtest: "The Walk-Forward Simulation" This is the most critical part. The code does not look at the whole history at once. It pretends to live through history day by day.
The Timeline:
Start Date: It goes back to the first day where it has enough data (Year 1).
Rebalance Day (e.g., Jan 31, 2015):
The algorithm "wakes up."
It looks only at data available before Jan 31.
It picks the Top 10 / Bottom 10 stocks based on that past data.
It buys them.
The "Walk" (Feb 1 - Feb 28, 2015):
It holds those stocks for exactly one month.
It records the profit or loss from those specific stocks.
Repeat: On Feb 28, it sells everything, re-runs the scan, picks new winners/losers, and holds for March.
- Why Long-Short vs. Long-Only? The block runs two parallel simulations to show you the difference:
Long-Only (The Green Line):
It just buys the Top 10 winners.
Logic: "I want maximum growth."
Risk: If the market crashes (like 2008 or 2020), this line will crash hard because it has no protection.
Long-Short (The Purple Line):
It buys the Top 10 winners AND shorts the Bottom 10 losers.
Logic: 0 cost portfolio, net long-short is 0
The Hedge: If the market crashes 20%, your Longs lose money, BUT your Shorts (the bad stocks) likely crash even harder (e.g., 30%), making you a profit on the way down.
Result: A smoother equity curve that is safer during crashes, but might lag during raging bull markets.
This won't hence be a perfect backtest as we are missing a key part of the equation, on the other hand we cannot assume that the Book-to-market todays is the same it is today, as this can change dramatically over time. By removing the "Value" factor from this specific block, we are answering the question: Even without this data, does the momentum strategy based on price action alone have an edge?
================================================================================
FINAL REPORT: PURE MOMENTUM BACKTEST
================================================================================
... Pre-calculating Momentum Factors ...
> Simulating [LONG-ONLY] (61 rebalances)...
100%|██████████████████████████████████████████████████████████████████████████████████| 60/60 [00:01<00:00, 42.73it/s]
> Simulating [LONG-SHORT] (61 rebalances)...
100%|██████████████████████████████████████████████████████████████████████████████████| 60/60 [00:01<00:00, 38.55it/s]
================================================================================
PERFORMANCE METRICS
================================================================================
Strategy Total Return CAGR Volatility Sharpe Ratio Max DD
Long-Only 325.55% 33.77% 30.89% 0.96 -31.52%
Long-Short 50.70% 8.59% 19.49% 0.24 -35.37%
Benchmark 86.99% 13.40% 18.62% 0.50 -21.98%
--------------------------------------------------------------------------------
================================================================================
TRADING JOURNAL: MONTHLY PERFORMANCE LOG
================================================================================
Generating Journal for last 6 months...
📅 PERIOD: 2025-07-31 to 2025-08-31
--------------------------------------------------------------------------------
[LONG-ONLY STRATEGY]
💰 Value: £32,883 | 📈 Return: -2.51% (PnL: £-846)
🟢 BUYS: VST, PLTR, CVNA, NRG, APP, FIX, UAL, TPR, ORCL, IBKR
🔴 SELLS: -
----------------------------------------
[LONG-SHORT STRATEGY]
💰 Value: £13,315 | 📈 Return: -5.16% (PnL: £-724)
🟢 LONG ADD: PLTR, NRG, FIX, TPR, VST, CVNA, APP, UAL, ORCL, IBKR
🔴 LONG CUT: -
📉 SHORT ADD: UNH, CAG, SWKS, INTC, ALGN, ELV, CNC, LYB, UPS, DOW
🔄 COVER: -
📊 ALLOCATION: PLTR(+5.4%), CNC(-5.3%), DOW(-5.3%), TPR(+5.3%), APP(+5.2%), UNH(-5.2%), CVNA(+5.2%), ELV(-5.1%), FIX(+5.1%), VST(+5.1%), IBKR(+5.0%), INTC(-5.0%), SWKS(-5.0%), UAL(+4.9%), ORCL(+4.8%), NRG(+4.8%), UPS(-4.7%), CAG(-4.6%), LYB(-4.6%), ALGN(-4.5%)
📅 PERIOD: 2025-08-31 to 2025-09-30
--------------------------------------------------------------------------------
[LONG-ONLY STRATEGY]
💰 Value: £34,181 | 📈 Return: +3.95% (PnL: £+1,298)
🟢 BUYS: WYNN, EXPE, RCL, LYV, SYF, STX, PODD, CCL
🔴 SELLS: PLTR, NRG, FIX, TPR, VST, CVNA, ORCL, IBKR
----------------------------------------
[LONG-SHORT STRATEGY]
💰 Value: £13,806 | 📈 Return: +3.69% (PnL: £+491)
🟢 LONG ADD: RCL, SYF, STX, CCL, WYNN, EXPE, LYV, PODD
🔴 LONG CUT: FIX, CVNA, ORCL, IBKR, PLTR, NRG, TPR, VST
📉 SHORT ADD: ADBE, CDW, ON, IFF, STZ, COO, IT, MRNA, TGT
🔄 COVER: CAG, SWKS, ELV, UPS, DOW, UNH, INTC, ALGN, CNC
📊 ALLOCATION: APP(+5.9%), MRNA(-5.9%), UAL(+5.7%), IT(-5.6%), RCL(+5.6%), ON(-5.1%), LYV(+5.1%), IFF(-5.0%), STZ(-4.9%), COO(-4.8%), PODD(+4.8%), CCL(+4.8%), WYNN(+4.8%), TGT(-4.7%), LYB(-4.7%), SYF(+4.7%), ADBE(-4.5%), CDW(-4.5%), STX(+4.4%), EXPE(+4.4%)
📅 PERIOD: 2025-09-30 to 2025-10-31
--------------------------------------------------------------------------------
[LONG-ONLY STRATEGY]
💰 Value: £36,777 | 📈 Return: +7.59% (PnL: £+2,596)
🟢 BUYS: DASH, HOOD, PLTR, FIX, TPR, HWM, WDC, IBKR
🔴 SELLS: WYNN, EXPE, RCL, LYV, SYF, UAL, PODD, CCL
----------------------------------------
[LONG-SHORT STRATEGY]
💰 Value: £14,457 | 📈 Return: +4.72% (PnL: £+651)
🟢 LONG ADD: DASH, FIX, HWM, IBKR, HOOD, PLTR, TPR, WDC
🔴 LONG CUT: RCL, SYF, CCL, WYNN, EXPE, LYV, UAL, PODD
📉 SHORT ADD: ERIE, DOW, TTD, ALGN, BAX, DECK, BF-B
🔄 COVER: ADBE, TGT, CDW, ON, COO, IT, MRNA
📊 ALLOCATION: APP(+5.3%), HOOD(+5.3%), PLTR(+5.2%), TTD(-5.1%), FIX(+5.1%), ALGN(-5.1%), STZ(-5.1%), LYB(-5.1%), TPR(+5.1%), STX(+5.0%), WDC(+5.0%), IBKR(+4.9%), HWM(+4.9%), DASH(+4.9%), BF-B(-4.9%), ERIE(-4.9%), DOW(-4.9%), BAX(-4.8%), IFF(-4.8%), DECK(-4.7%)
📅 PERIOD: 2025-10-31 to 2025-11-30
--------------------------------------------------------------------------------
[LONG-ONLY STRATEGY]
💰 Value: £37,034 | 📈 Return: +0.70% (PnL: £+258)
🟢 BUYS: APH, MU, AVGO, WBD, LRCX, GLW
🔴 SELLS: DASH, HOOD, TPR, APP, STX, IBKR
----------------------------------------
[LONG-SHORT STRATEGY]
💰 Value: £14,547 | 📈 Return: +0.62% (PnL: £+90)
🟢 LONG ADD: APH, MU, AVGO, WBD, GLW, LRCX
🔴 LONG CUT: DASH, APP, STX, IBKR, HOOD, TPR
📉 SHORT ADD: MOH, CAG, CMG, ARE, SWK, FISV, BLDR
🔄 COVER: DOW, IFF, TTD, STZ, ALGN, LYB, BF-B
📊 ALLOCATION: WBD(+5.4%), WDC(+5.3%), FIX(+5.3%), MOH(-5.2%), FISV(-5.2%), DECK(-5.2%), APH(+5.2%), MU(+5.1%), BAX(-5.1%), AVGO(+5.1%), CMG(-5.1%), PLTR(+5.0%), GLW(+4.9%), HWM(+4.9%), LRCX(+4.9%), ARE(-4.9%), BLDR(-4.7%), CAG(-4.6%), ERIE(-4.5%), SWK(-4.5%)
📅 PERIOD: 2025-11-30 to 2025-12-31
--------------------------------------------------------------------------------
[LONG-ONLY STRATEGY]
💰 Value: £36,910 | 📈 Return: -0.33% (PnL: £-124)
🟢 BUYS: DLTR, NEM, RL, CAH, GOOG, IDXX, GOOGL
🔴 SELLS: PLTR, FIX, APH, MU, LRCX, HWM, GLW
----------------------------------------
[LONG-SHORT STRATEGY]
💰 Value: £14,332 | 📈 Return: -1.47% (PnL: £-214)
🟢 LONG ADD: DLTR, NEM, CAH, GOOG, IDXX, GOOGL, RL
🔴 LONG CUT: FIX, APH, MU, HWM, GLW, PLTR, LRCX
📉 SHORT ADD: ADBE, UNH, CHTR, TTD, IT, TPL, MRNA
🔄 COVER: CAG, ERIE, CMG, SWK, BLDR, DECK, BAX
📊 ALLOCATION: TTD(-5.6%), WDC(+5.5%), CHTR(-5.3%), WBD(+5.2%), IT(-5.2%), FISV(-5.2%), NEM(+5.0%), ARE(-5.0%), MRNA(-4.9%), IDXX(+4.9%), RL(+4.9%), DLTR(+4.9%), GOOGL(+4.9%), TPL(-4.8%), GOOG(+4.8%), UNH(-4.8%), CAH(+4.8%), ADBE(-4.8%), AVGO(+4.8%), MOH(-4.7%)
📅 PERIOD: 2025-12-31 to 2026-01-31
--------------------------------------------------------------------------------
[LONG-ONLY STRATEGY]
💰 Value: £42,888 | 📈 Return: +16.20% (PnL: £+5,978)
🟢 BUYS: MU, TPR, C, LRCX, HII, DG
🔴 SELLS: AVGO, RL, CAH, GOOG, IDXX, GOOGL
----------------------------------------
[LONG-SHORT STRATEGY]
💰 Value: £15,055 | 📈 Return: +5.04% (PnL: £+723)
🟢 LONG ADD: MU, TPR, C, LRCX, HII, DG
🔴 LONG CUT: AVGO, CAH, GOOG, IDXX, GOOGL, RL
📉 SHORT ADD: POOL, ZBRA, PYPL, BLDR, GDDY, CLX, LYB, BF-B
🔄 COVER: ADBE, MOH, UNH, CHTR, FISV, IT, TPL, MRNA
📊 ALLOCATION: MU(+5.5%), WBD(+5.4%), NEM(+5.3%), TPR(+5.2%), ARE(-5.2%), WDC(+5.1%), TTD(-5.1%), LRCX(+5.1%), BF-B(-5.0%), HII(+5.0%), BLDR(-4.9%), DLTR(+4.9%), LYB(-4.9%), DG(+4.9%), C(+4.8%), PYPL(-4.8%), POOL(-4.8%), ZBRA(-4.8%), CLX(-4.7%), GDDY(-4.7%)
✅ Performance Log Complete.
------- BETA-HEDGED WALK-FORWARD (Market Neutral) -----------
This block implements a Beta-Neutral Momentum Strategy.¶
Unlike the previous "Dollar Neutral" (50% Long / 50% Short) approach, this strategy calculates the Beta (volatility relative to the market) of your Longs vs. your Shorts.
Scenario: If your Longs are very volatile (High Beta) and your Shorts are stable (Low Beta), a 50/50 portfolio is actually Net Long risk.
The Fix: This algorithm calculates a Hedge Ratio (e.g., 1.5x) and increases the size of the Short position to mathematically neutralize market risk.
--- CONFIGURATION ---¶
LOOKBACK_BETA = 126 # 6 Months for Beta Calculation LOOKBACK_MOM = 252 # 12 Months for Trend REBALANCE_FREQ = 'ME' # Monthly NUM_POSITIONS = 10 # Top 10 Winners / Bottom 10 Losers TX_COST = 0.001 # 0.10% per trade RF_RATE = last_rf # last Risk-Free Rate
================================================================================
STRATEGY: BETA-HEDGED MARKET NEUTRAL
================================================================================
⚙️ Config: Top 10 L/S | Risk-Free Rate: 4.24%
... Pre-calculating Momentum and Beta Factors ...
> Simulating 64 periods...
100%|██████████████████████████████████████████████████████████████████████████████████| 63/63 [00:01<00:00, 36.05it/s]
METRIC | RESULT ----------------------------------- Total Return | 62.07% CAGR (Annual) | 9.67% Max Drawdown | -45.12% Sharpe Ratio | 0.03 Avg Hedge Ratio | 1.16 x Note: A Hedge Ratio > 1.0 means your Longs are more volatile than your Shorts, so you increased your Short size to compensate (and vice versa).
================================================================================
TRADING JOURNAL: BETA-HEDGED STRATEGY LOG
================================================================================
Reconstructing trades for the last 6 periods...
(Linking to Block 8 results for strict accuracy)
📅 PERIOD: 2025-07-31 to 2025-08-29
--------------------------------------------------------------------------------
💰 Value: £14,214 | 📈 Month Return: -3.68% (PnL: £-542)
⚖️ HEDGE RATIO: 1.61x (Short Size Multiplier)
----------------------------------------
🟢 LONG ENTRY: AXON, DASH, HOOD, PLTR, NRG, TPR, VST, CVNA, APP, HWM
🔴 LONG EXIT: -
📉 SHORT ENTRY: UNH, REGN, TER, CNC, BIIB, SMCI, HAL, ARE, DOW, MRNA
🔄 SHORT COVER: -
📊 PORTFOLIO: UNH(-16.1%), BIIB(-16.1%), DOW(-16.1%), TER(-16.1%), ARE(-16.1%), HAL(-16.1%), CNC(-16.1%), SMCI(-16.1%), MRNA(-16.1%), REGN(-16.1%), DASH(+10.0%), CVNA(+10.0%), VST(+10.0%), HWM(+10.0%), PLTR(+10.0%), HOOD(+10.0%), TPR(+10.0%), NRG(+10.0%), APP(+10.0%), AXON(+10.0%)
(Net Exposure: -60.8% | Gross: 260.8%)
📅 PERIOD: 2025-08-29 to 2025-09-30
--------------------------------------------------------------------------------
💰 Value: £15,064 | 📈 Month Return: +5.98% (PnL: £+850)
⚖️ HEDGE RATIO: 2.00x (Short Size Multiplier)
----------------------------------------
🟢 LONG ENTRY: JBL, FIX, IBKR, UAL
🔴 LONG EXIT: DASH, HWM, AXON, NRG
📉 SHORT ENTRY: CAG, MOH, ELV, ALGN
🔄 SHORT COVER: TER, ARE, SMCI, HAL
📊 PORTFOLIO: ALGN(-20.0%), ELV(-20.0%), REGN(-20.0%), DOW(-20.0%), CAG(-20.0%), BIIB(-20.0%), UNH(-20.0%), MOH(-20.0%), CNC(-20.0%), MRNA(-20.0%), VST(+10.0%), CVNA(+10.0%), FIX(+10.0%), IBKR(+10.0%), HOOD(+10.0%), PLTR(+10.0%), JBL(+10.0%), UAL(+10.0%), APP(+10.0%), TPR(+10.0%)
(Net Exposure: -100.0% | Gross: 300.0%)
📅 PERIOD: 2025-09-30 to 2025-10-31
--------------------------------------------------------------------------------
💰 Value: £14,622 | 📈 Month Return: -2.93% (PnL: £-442)
⚖️ HEDGE RATIO: 1.64x (Short Size Multiplier)
----------------------------------------
🟢 LONG ENTRY: RCL
🔴 LONG EXIT: JBL
📉 SHORT ENTRY: ADBE, TTD, IT
🔄 SHORT COVER: CAG, ALGN, BIIB
📊 PORTFOLIO: UNH(-16.4%), DOW(-16.4%), MOH(-16.4%), TTD(-16.4%), ADBE(-16.4%), ELV(-16.4%), IT(-16.4%), REGN(-16.4%), MRNA(-16.4%), CNC(-16.4%), VST(+10.0%), TPR(+10.0%), UAL(+10.0%), RCL(+10.0%), HOOD(+10.0%), APP(+10.0%), IBKR(+10.0%), FIX(+10.0%), PLTR(+10.0%), CVNA(+10.0%)
(Net Exposure: -63.8% | Gross: 263.8%)
📅 PERIOD: 2025-10-31 to 2025-11-28
--------------------------------------------------------------------------------
💰 Value: £14,689 | 📈 Month Return: +0.45% (PnL: £+67)
⚖️ HEDGE RATIO: 0.75x (Short Size Multiplier)
----------------------------------------
🟢 LONG ENTRY: WBD, TSLA, STX, WDC
🔴 LONG EXIT: RCL, IBKR, VST, UAL
📉 SHORT ENTRY: BF-B, STZ, ALGN, LYB, TGT
🔄 SHORT COVER: ADBE, MOH, ELV, UNH, REGN
📊 PORTFOLIO: HOOD(+10.0%), APP(+10.0%), PLTR(+10.0%), TPR(+10.0%), WDC(+10.0%), WBD(+10.0%), STX(+10.0%), CVNA(+10.0%), FIX(+10.0%), TSLA(+10.0%), STZ(-7.5%), ALGN(-7.5%), BF-B(-7.5%), LYB(-7.5%), TGT(-7.5%), CNC(-7.5%), MRNA(-7.5%), IT(-7.5%), DOW(-7.5%), TTD(-7.5%)
(Net Exposure: 24.6% | Gross: 175.4%)
📅 PERIOD: 2025-11-28 to 2025-12-31
--------------------------------------------------------------------------------
💰 Value: £14,442 | 📈 Month Return: -1.68% (PnL: £-247)
⚖️ HEDGE RATIO: 0.77x (Short Size Multiplier)
----------------------------------------
🟢 LONG ENTRY: MU, AVGO, LRCX, SMCI
🔴 LONG EXIT: FIX, CVNA, TSLA, APP
📉 SHORT ENTRY: MOH, LULU, CMG, FDS, ARE, FISV, DECK
🔄 SHORT COVER: TGT, DOW, ALGN, CNC, LYB, MRNA, BF-B
📊 PORTFOLIO: HOOD(+10.0%), PLTR(+10.0%), WDC(+10.0%), STX(+10.0%), WBD(+10.0%), SMCI(+10.0%), TPR(+10.0%), MU(+10.0%), AVGO(+10.0%), LRCX(+10.0%), FDS(-7.7%), STZ(-7.7%), ARE(-7.7%), CMG(-7.7%), LULU(-7.7%), MOH(-7.7%), DECK(-7.7%), IT(-7.7%), TTD(-7.7%), FISV(-7.7%)
(Net Exposure: 23.0% | Gross: 177.0%)
📅 PERIOD: 2025-12-31 to 2026-01-23
--------------------------------------------------------------------------------
💰 Value: £16,207 | 📈 Month Return: +12.23% (PnL: £+1,766)
⚖️ HEDGE RATIO: 0.83x (Short Size Multiplier)
----------------------------------------
🟢 LONG ENTRY: FIX, NEM, INTC
🔴 LONG EXIT: AVGO, TPR, SMCI
📉 SHORT ENTRY: CHTR, MRNA
🔄 SHORT COVER: FDS, STZ
📊 PORTFOLIO: WDC(+10.0%), HOOD(+10.0%), STX(+10.0%), MU(+10.0%), NEM(+10.0%), PLTR(+10.0%), INTC(+10.0%), LRCX(+10.0%), WBD(+10.0%), FIX(+10.0%), MRNA(-8.3%), ARE(-8.3%), CMG(-8.3%), CHTR(-8.3%), MOH(-8.3%), LULU(-8.3%), IT(-8.3%), DECK(-8.3%), FISV(-8.3%), TTD(-8.3%)
(Net Exposure: 16.8% | Gross: 183.2%)
✅ Beta-Hedged Journal Complete.
===============================================================================================
HEAD-TO-HEAD: BETA HEDGED vs DOLLAR NEUTRAL vs S&P 500
===============================================================================================
✅ Linked to Block 8: Using existing Beta-Hedged curve (61 periods).
> Simulating [DOLLAR_NEUTRAL] (Static 1.0 Hedge)...
100%|██████████████████████████████████████████████████████████████████████████████████| 60/60 [00:01<00:00, 32.52it/s]
> Retrieving Benchmark (S&P 500 GBP)...
METRIC | BETA HEDGED | DOLLAR NEUTRAL | BENCHMARK -------------------------------------------------------------------------------- Total Return | 62.07% | 129.82% | 103.74% CAGR | 9.67% | 17.24% | 14.57% Volatility | 36.16% | 38.33% | 12.95% Sharpe Ratio | 0.15 | 0.34 | 0.80 Max Drawdown | -45.12% | -46.28% | -14.59% -------------------------------------------------------------------------------- 🏆 FINAL VERDICT: Benchmark wins with Sharpe 0.80 ================================================================================ I won't consider these strategies for this type of momentum trading as the Sharpe ratios are consistently very low, and substantially below the benchmark Sharpe. ================================================================================
1. The "Crystal Ball" Effect¶
The portfolio so far can be seen as The Honest Backtests: These simulations "walked forward" through time. In 2021, they did not know which stocks would crash in 2022. They had to pick from the entire universe each time the top 10 winners and the top 10 losers. That is why those results looked realistic (and sometimes messy).
2. The mathematically "perfect" portfolios¶
The following portfolio will use Optimization: These blocks started with the final_longs list—the "Survivors" that passed your strict filters TODAY.
You effectively asked: "If I had picked the 10 best stocks of 2025 back in 2024, how would I have done?"
The answer is obviously "Amazing," because you already removed every stock that failed along the way.
3. So, why do we want this optimised portfolios??¶
If the returns are biased, is the code useless? No.
We use these blocks for Risk Estimation, not Return Prediction.
Useless Metric: The "Expected Return" (e.g., 80% annualized). You will likely not get this next month. The momentum will fade.
Useful Metric: The Covariance & Correlation (The "Safe" vs "Aggressive" split).
Even though the returns are biased, the way these stocks move together (correlation) is usually stable.
If we see that Stock A and Stock B move in opposite directions, you should hold them both, so you lower your risk.
================================================================================
PORTFOLIO OPTIMIZATION: MAX SHARPE vs INVERSE VOLATILITY
================================================================================
📥 Input Source: Block 4 (Refined Longs) (41 Tickers)
✂️ Capping at Top 10 (Best Momentum Score).
💎 Optimization Universe: WDC, STX, MU, NEM, LRCX, CVNA, FIX, APH, HII, GLW
💾 OPTIMIZATION EXPORTS COMPLETE:
1. Max Sharpe Portfolio: Optimization_MaxSharpe_Range_2025-02-06_to_2026-01-23_Created_20260125_1720.csv
2. Inverse Volatility Port: Optimization_InvVol_Range_2025-02-06_to_2026-01-23_Created_20260125_1720.csv
[PREVIEW: MAX SHARPE PORTFOLIO (Aggressive)]
Exp_Return Exp_Volatility Weight
HII 96.60% 33.46% 44.39%
NEM 104.50% 41.03% 26.34%
WDC 168.81% 59.84% 18.40%
MU 156.32% 62.01% 10.87%
[PREVIEW: INVERSE VOLATILITY PORTFOLIO (Defensive)]
Exp_Return Exp_Volatility Weight
HII 96.60% 33.46% 13.99%
APH 75.93% 34.53% 13.56%
GLW 55.92% 35.67% 13.13%
NEM 104.50% 41.03% 11.41%
LRCX 102.64% 50.28% 9.31%
FIX 94.62% 55.44% 8.45%
STX 137.93% 56.49% 8.29%
WDC 168.81% 59.84% 7.82%
MU 156.32% 62.01% 7.55%
CVNA 77.05% 72.14% 6.49%
CREATING 3 PORTFOLIOS ALLOWING SHORTSELLING:¶
WEIGHTS ARE CALCULATED --> MAX SHARPE OPTIMISATION - INVERSE VOLATILITY - EQUAL WEIGHTS
===============================================================================================
PREDICTIVE ENGINE: OFFICIAL TRADING SIGNALS
===============================================================================================
📥 Input: Using candidates directly from Block 4.
💎 FINAL SELECTION:
• Longs (10): WDC, MU, STX, NEM, HII, LRCX, ALB, FIX, AMD, INTC
• Shorts (10): FISV, TTD, IT, LULU, GDDY, CHTR, DECK, FDS, HPQ, DVA
... optimizing allocations ...
===============================================================================================
🏆 OFFICIAL TRADING SIGNALS (NEXT REBALANCE) 🏆
===============================================================================================
TICKER | SIDE | MOMENTUM | AGGRESSIVE | SAFE (VOL) | EQUAL | ACTION
-----------------------------------------------------------------------------------------------
HII | LONG | 148.4% | 43.3% ★| 15.7% | 10.0% | BUY
NEM | LONG | 160.9% | 25.6% ★| 12.8% | 10.0% | BUY
WDC | LONG | 350.9% | 18.0% ★| 8.8% | 10.0% | BUY
MU | LONG | 292.8% | 8.6% | 8.5% | 10.0% | BUY
INTC | LONG | 115.4% | 3.3% | 7.7% | 10.0% | BUY
ALB | LONG | 126.8% | 1.2% | 8.6% | 10.0% | BUY
FIX | LONG | 121.9% | 0.0% | 9.5% | 10.0% | BUY
AMD | LONG | 118.3% | 0.0% | 8.8% | 10.0% | BUY
LRCX | LONG | 145.9% | 0.0% | 10.4% | 10.0% | BUY
STX | LONG | 238.5% | 0.0% | 9.3% | 10.0% | BUY
GDDY | SHORT | -54.5% | 28.1% ★| 12.4% | 10.0% | SELL SHORT
IT | SHORT | -59.8% | 17.5% ★| 9.6% | 10.0% | SELL SHORT
FISV | SHORT | -72.9% | 16.2% ★| 7.0% | 10.0% | SELL SHORT
CHTR | SHORT | -49.8% | 13.0% | 10.9% | 10.0% | SELL SHORT
FDS | SHORT | -42.8% | 9.3% | 14.1% | 10.0% | SELL SHORT
DVA | SHORT | -41.8% | 8.1% | 13.2% | 10.0% | SELL SHORT
LULU | SHORT | -57.0% | 7.1% | 8.3% | 10.0% | SELL SHORT
TTD | SHORT | -70.5% | 0.5% | 5.5% | 10.0% | SELL SHORT
DECK | SHORT | -46.2% | 0.0% | 8.1% | 10.0% | SELL SHORT
HPQ | SHORT | -42.4% | 0.0% | 11.0% | 10.0% | SELL SHORT
-----------------------------------------------------------------------------------------------
NOTE: Aggressive = Max Sharpe Ratio | Safe = Inverse Volatility | Equal = 1/N
💾 SAVING PORTFOLIOS TO CSV... ✅ Saved MaxSharpe : Forecast_MaxSharpe_ShortSellingAllowed_Range_2025-02-06_to_2026-01-23_Created_20260125_1720.csv ✅ Saved InverseVol : Forecast_InverseVol_ShortSellingAllowed_Range_2025-02-06_to_2026-01-23_Created_20260125_1720.csv ✅ Saved EqualWeight : Forecast_EqualWeight_ShortSellingAllowed_Range_2025-02-06_to_2026-01-23_Created_20260125_1720.csv ✅ FORECAST GENERATED AND SAVED.
================================================================================
FORENSIC ANALYSIS: WEIGHT DIVERGENCE CHECK
================================================================================
📊 VOLATILITY SPREAD ANALYSIS:
Min Volatility: 33.46%
Max Volatility: 68.42%
Spread: 34.96%
💡 CONCLUSION: Your candidates are HETEROGENEOUS.
There is a significant difference in risk profiles.
Weight Correlation: 0.8463
--------------------------------------------------------------------------------
Vol (Ann) Wgt_Aggressive Wgt_Safe Wgt_Equal
Asset
HII 33.46% 43.32% 15.70% 10.00%
NEM 41.03% 25.58% 12.80% 10.00%
LRCX 50.28% 0.00% 10.45% 10.00%
FIX 55.44% 0.00% 9.48% 10.00%
STX 56.49% 0.00% 9.30% 10.00%
WDC 59.84% 17.97% 8.78% 10.00%
AMD 59.90% 0.00% 8.77% 10.00%
ALB 61.31% 1.22% 8.57% 10.00%
MU 62.01% 8.64% 8.47% 10.00%
INTC 68.42% 3.27% 7.68% 10.00%
--------------------------------------------------------------------------------
✅ PROOF-CHECK COMPLETE.
================================================================================
RISK FORECAST: NEXT MONTH SIMULATION (21 DAYS)
================================================================================
🔎 PORTFOLIO DIVERSIFICATION CHECK:
------------------------------------------------------------
Aggressive vs Safe Correlation: 0.7448
✅ Strategies are distinct (Good Diversification).
------------------------------------------------------------
📊 EXPECTED RISK PROFILE (ANNUALIZED)
--------------------------------------------------------------------------------
STRATEGY | EXP RETURN | VOLATILITY | SHARPE | VaR (95%)
--------------------------------------------------------------------------------
Aggressive | 110.9% | 19.0% | 5.62 | -9.1%
Safe | 110.7% | 19.5% | 5.47 | -9.3%
Equal Wgt | 116.2% | 21.0% | 5.36 | -10.0%
--------------------------------------------------------------------------------
Note: VaR (95%) = Maximum expected monthly loss with 95% confidence.
✅ SIMULATION COMPLETE.
VERIFICATION: DID THE PREVIOUS MONTH'S FORECAST COME TRUE?¶
Sets up the "Time Machine": It rewinds the clock by 21 trading days (approximately one month), establishing a "Hypothetical Decision Date." It then defines a "Test Period" from that decision date to the present (the "Unknown Future").
Runs a Blind Forecast: It strictly slices the data (prices_stocks) to include only history up to the decision date. It then calculates the 12-month momentum, applies a 200-day Moving Average trend filter (just like the live strategy), and selects the top 10 stocks. This simulates exactly what the algorithm would have picked back then without knowing the future.
Optimizes the Blind Portfolio: It runs the "Max Sharpe" optimization on those blind picks using the limited history, determining the optimal weights.
Verifies Performance (The Reveal): It then fast-forwards to the present and calculates how that specific portfolio actually performed over the last 21 days (future_prices). It aligns the portfolio returns with the real market data.
Benchmarks Results: It compares the strategy's performance against the S&P 500 (converted to GBP) over the same period.
Generates a Report Card: It prints a clear summary of the Strategy Return vs. Benchmark Return, the Alpha (Excess Return), and a detailed breakdown of each ticker's predicted weight vs. its actual return.
Visualizes the Result: It plots an equity curve showing the strategy's performance against the benchmark during this out-of-sample test period.
================================================================================
VERIFICATION: DID THE PREVIOUS MONTH'S FORECAST COME TRUE?
================================================================================
⚙️ SIMULATION PARAMETERS:
• Hypothetical Decision Date: 2025-12-26
• Blind Trend Window: 2025-01-08 -> 2025-12-26
• Verification Period: 2025-12-26 -> 2026-01-23 (The 'Hidden' Month)
🔎 PAST PREDICTIONS (Made on 2025-12-26):
• Top Blind Pick: WDC (Trend: 244.4%)
... Optimizing Blind Portfolio (Max Sharpe) ...
============================================================
VERIFICATION RESULTS
============================================================
Strategy Return (Last 21 Days): +9.93% (✅ PROFIT)
Benchmark Return (S&P 500): +0.43%
Alpha (Excess Return): +9.51%
------------------------------------------------------------
TICKER | PREDICTED WEIGHT | ACTUAL RETURN
------------------------------------------------------------
NEM | 30.75% | +17.58% ✅
WBD | 26.42% | -0.71% 🔻
WDC | 22.39% | +30.29% ✅
APP | 13.94% | -26.54% 🔻
MU | 6.49% | +40.47% ✅
------------------------------------------------------------
===============================================================================================
VERIFICATION: AUDITING ALL 6 STRATEGY VARIANTS (LAST 21 DAYS)
===============================================================================================
⚙️ SIMULATION PARAMETERS:
• Decision Date (Past): 2025-12-26
• Verification Period: 2025-12-26 -> 2026-01-23
🔎 PAST PICKS (2025-12-26):
• Top Long: WDC
• Top Short: TTD
... Calculating Blind Weights ...
================================================================================
VERIFICATION RESULTS
================================================================================
STRATEGY | RETURN | OUTCOME
--------------------------------------------------------------------------------
Long: Aggressive | 9.93% | ✅ BEAT MKT
Long: Safe | 9.00% | ✅ BEAT MKT
Long: Equal | 8.36% | ✅ BEAT MKT
L/S: Aggressive | 6.10% | ✅ BEAT MKT
L/S: Equal | 2.83% | ✅ BEAT MKT
L/S: Safe | 2.50% | ✅ BEAT MKT
Benchmark | 0.43% | ---
--------------------------------------------------------------------------------
🏆 WINNER (Last Month): Long: Aggressive
================================================================================
🔍 STRATEGIC TAKEAWAY:
--------------------------------------------------------------------------------
• I would expect the LONG AGGRESSIVE portfolio to do well during strong Bull Markets.
• The DEFENSIVE (Safe/Hedged) portfolios may underperform during these periods.
• However, the DEFENSIVE and HEDGED portfolios should outperform Aggressive (and Long-Only)
portfolios during Bear Markets or periods of weak overall market performance.
================================================================================
Next block acts as your "Quality Control" department.¶
It answers two critical questions before you risk real money:
Are these trends real? (Hurst Exponent)¶
We want to buy stocks that are mathematically "Persistent" (trending). If the Hurst Exponent is 0.5, the price movement is a random walk (gambling).
The trend-detection module of this algorithm relies on Rescaled Range (R/S) Analysis, a statistical method originally developed by Hurst (1951) to measure the long-term persistence of time series data. Although traditional finance assumes asset prices follow a Random Walk, empirical research by Mandelbrot (1963) and Peters (1994) demonstrates that financial markets exhibit 'Long Memory' effects (Macrosynergy, 2023). As proved by Mitra et al. (2012) finding a high value of H exponent indicate the presence of long memory in the time series, in which case future value will depend partially on past values of the series. In other worlds the past price is an indicator of future performance (in the short term).
Are we doubling up on risk? (Correlation)¶
If you buy 5 different stocks but they all have a 95% correlation (e.g., 5 Energy stocks), you haven't diversified; you've just placed one giant bet.
Macrosynergy (2023). Detecting trends and mean reversion with the Hurst exponent | Macrosynergy. [online] Macrosynergy. Available at: https://macrosynergy.com/research/detecting-trends-and-mean-reversion-with-the-hurst-exponent/. Mitra, Suman. (2012). Is Hurst Exponent Value Useful in Forecasting Financial Time Series?. Asian Social Science. 8. 111-111. 10.5539/ass.v8n8p111.
================================================================================
STATISTICAL VALIDATION: ARE THESE TRENDS ROBUST?
================================================================================
📥 Loaded 41 Longs from Block 4.
📥 Loaded 26 Shorts from Block 4.
🔬 Analyzing 67 candidates for statistical robustness...
TICKER | SIDE | HURST | VOL | VERDICT
-----------------------------------------------------------------
CAH | LONG | 0.59 | 27.4% | STRONG TREND
IT | SHORT | 0.56 | 43.1% | STRONG TREND
CHTR | SHORT | 0.56 | 38.1% | STRONG TREND
CMI | LONG | 0.56 | 31.8% | STRONG TREND
RL | LONG | 0.55 | 38.5% | RANDOM WALK
AMAT | LONG | 0.55 | 46.5% | RANDOM WALK
DECK | SHORT | 0.54 | 51.4% | RANDOM WALK
FDS | SHORT | 0.53 | 29.4% | RANDOM WALK
LULU | SHORT | 0.53 | 50.0% | RANDOM WALK
IVZ | LONG | 0.53 | 39.8% | RANDOM WALK
PCG | SHORT | 0.53 | 27.7% | RANDOM WALK
HPQ | SHORT | 0.53 | 37.7% | RANDOM WALK
GOOGL | LONG | 0.53 | 32.0% | RANDOM WALK
AMD | LONG | 0.52 | 60.0% | RANDOM WALK
CDW | SHORT | 0.52 | 32.7% | RANDOM WALK
GOOG | LONG | 0.52 | 31.6% | RANDOM WALK
MU | LONG | 0.52 | 62.1% | RANDOM WALK
JNJ | LONG | 0.51 | 19.2% | RANDOM WALK
DLTR | LONG | 0.51 | 43.1% | RANDOM WALK
LRCX | LONG | 0.50 | 50.4% | RANDOM WALK
CRM | SHORT | 0.50 | 33.0% | RANDOM WALK
NOW | SHORT | 0.50 | 39.7% | RANDOM WALK
GS | LONG | 0.49 | 32.1% | RANDOM WALK
EL | LONG | 0.49 | 45.8% | RANDOM WALK
GLW | LONG | 0.48 | 35.7% | RANDOM WALK
INTC | LONG | 0.48 | 68.6% | RANDOM WALK
JBL | LONG | 0.48 | 41.4% | RANDOM WALK
COR | LONG | 0.48 | 22.0% | RANDOM WALK
SWKS | SHORT | 0.48 | 44.7% | RANDOM WALK
MPWR | LONG | 0.48 | 56.8% | RANDOM WALK
CAT | LONG | 0.47 | 32.9% | RANDOM WALK
HWM | LONG | 0.47 | 35.0% | RANDOM WALK
ZBRA | SHORT | 0.47 | 46.0% | RANDOM WALK
LHX | LONG | 0.46 | 23.3% | RANDOM WALK
ALB | LONG | 0.46 | 61.4% | RANDOM WALK
GPN | SHORT | 0.46 | 40.8% | RANDOM WALK
DG | LONG | 0.45 | 37.1% | RANDOM WALK
BK | LONG | 0.45 | 23.6% | RANDOM WALK
CVNA | LONG | 0.45 | 72.3% | MEAN REVERTING
WDC | LONG | 0.44 | 60.0% | MEAN REVERTING
HAS | LONG | 0.44 | 35.7% | MEAN REVERTING
TTD | SHORT | 0.44 | 75.5% | MEAN REVERTING
PAYC | SHORT | 0.44 | 35.7% | MEAN REVERTING
KLAC | LONG | 0.44 | 44.7% | MEAN REVERTING
CHRW | LONG | 0.44 | 37.8% | MEAN REVERTING
APH | LONG | 0.44 | 34.6% | MEAN REVERTING
PYPL | SHORT | 0.42 | 34.8% | MEAN REVERTING
IDXX | LONG | 0.42 | 42.4% | MEAN REVERTING
STX | LONG | 0.40 | 56.6% | MEAN REVERTING
VRSK | SHORT | 0.40 | 25.0% | MEAN REVERTING
HII | LONG | 0.40 | 33.5% | MEAN REVERTING
FIX | LONG | 0.39 | 55.5% | MEAN REVERTING
BRO | SHORT | 0.38 | 25.6% | MEAN REVERTING
FISV | SHORT | 0.38 | 58.9% | MEAN REVERTING
MNST | LONG | 0.37 | 22.7% | MEAN REVERTING
CPB | SHORT | 0.37 | 28.1% | MEAN REVERTING
STLD | LONG | 0.36 | 36.8% | MEAN REVERTING
ZTS | SHORT | 0.35 | 29.1% | MEAN REVERTING
NEM | LONG | 0.34 | 41.1% | MEAN REVERTING
CVS | LONG | 0.34 | 30.7% | MEAN REVERTING
GDDY | SHORT | 0.34 | 33.4% | MEAN REVERTING
F | LONG | 0.33 | 32.2% | MEAN REVERTING
DVA | SHORT | 0.33 | 31.2% | MEAN REVERTING
ERIE | SHORT | 0.33 | 32.0% | MEAN REVERTING
RTX | LONG | 0.31 | 28.8% | MEAN REVERTING
TYL | SHORT | 0.30 | 27.7% | MEAN REVERTING
GIS | SHORT | 0.20 | 23.4% | MEAN REVERTING
-----------------------------------------------------------------
NOTE: We prefer Hurst > 0.55. Values near 0.50 imply randomness.
🔍 DIVERSIFICATION CHECK (Correlation Matrix)...
⚠️ CONCENTRATION RISK DETECTED: • GOOG and GOOGL are highly correlated (1.00). Holding both adds no diversification. • KLAC and LRCX are highly correlated (0.91). Holding both adds no diversification. • AMAT and KLAC are highly correlated (0.90). Holding both adds no diversification. • AMAT and LRCX are highly correlated (0.88). Holding both adds no diversification. • STX and WDC are highly correlated (0.87). Holding both adds no diversification. 💾 REPORT SAVED: Concentration_Risk_Report_20260125_1720.txt (Includes Correlation Warnings + Full Statistical Audit Table)
WHAT ABOUT USING MACHINE LEARNING TO PREDICT ACCURACY IN SIGNALS OF SECURITIES ?¶
This block introduces Machine Learning to validate your candidates. Instead of relying solely on linear correlations or past momentum, it trains a Random Forest Classifier for each individual stock.
According to Breiman (2001), Random Forests avoid the common pitfall of overfitting by leveraging the Law of Large Numbers. The algorithm achieves accuracy by injecting randomness into the training process. Additionally, it allows for self-validation through 'out-of-bag' estimation, providing concrete data on the model's predictive strength. Following the methodology of Khaidem et al. (2016), feature vectors were constructed using technical indicators (RSI, Volatility, SMA Distance) to capture non-linear market dynamics. I used this methodology to scan the sotck in my candicades list and see which stock is more predictable, so to use this filtered universe to optimise the portfolios.
Breiman, L., 2001. Random forests. Machine learning, 45(1), pp.5-32. Khaidem, L., Saha, S. and Dey, Sudeepa Roy (2016). Predicting the direction of stock market prices using random forest. [online] arXiv.org. Available at: https://arxiv.org/abs/1605.00003.
================================================================================
ML VALIDATION: AUDITING THE FULL STOCK UNIVERSE
================================================================================
📥 Loaded 67 candidates from Live Lists.
🔎 STARTING AUDIT ON 67 STOCKS...
(Training AI models for each ticker...)
TICKER | ACCURACY | PRIMARY DRIVER | VERDICT
--------------------------------------------------------------------------------
IVZ | 56.35% | Vol_20D | ⭐⭐ HIGH SIGNAL
DLTR | 54.72% | Vol_20D | ⭐ EDGE FOUND
ZBRA | 47.23% | Vol_20D | ❌ TRAP
LULU | 47.56% | Vol_20D | ❌ TRAP
JBL | 54.07% | RSI | ⭐ EDGE FOUND
FIX | 55.70% | Dist_SMA50 | ⭐⭐ HIGH SIGNAL
ERIE | 52.77% | Dist_SMA50 | ⭐ EDGE FOUND
NEM | 57.98% | RSI | ⭐⭐ HIGH SIGNAL
APH | 56.03% | RSI | ⭐⭐ HIGH SIGNAL
MNST | 55.05% | Vol_20D | ⭐⭐ HIGH SIGNAL
BK | 59.28% | Dist_SMA50 | ⭐⭐ HIGH SIGNAL
BRO | 46.91% | Vol_20D | ❌ TRAP
COR | 51.79% | Vol_20D | ⭐ EDGE FOUND
ZTS | 47.56% | Vol_20D | ❌ TRAP
FDS | 53.09% | Vol_20D | ⭐ EDGE FOUND
AMD | 52.12% | Vol_20D | ⭐ EDGE FOUND
PAYC | 46.25% | Vol_20D | ❌ TRAP
RTX | 63.84% | Dist_SMA50 | ⭐⭐ HIGH SIGNAL
CRM | 46.91% | Dist_SMA50 | ❌ TRAP
STLD | 53.42% | Dist_SMA50 | ⭐ EDGE FOUND
CAH | 51.47% | Vol_20D | ⭐ EDGE FOUND
LHX | 52.77% | Vol_20D | ⭐ EDGE FOUND
CVNA | 46.91% | Vol_20D | ❌ TRAP
HWM | 58.96% | Vol_20D | ⭐⭐ HIGH SIGNAL
DVA | 51.79% | Dist_SMA50 | ⭐ EDGE FOUND
CDW | 44.63% | Dist_SMA50 | ❌ TRAP
GOOG | 48.53% | Vol_20D | ❌ TRAP
IDXX | 53.09% | RSI | ⭐ EDGE FOUND
AMAT | 46.58% | Vol_20D | ❌ TRAP
PYPL | 51.14% | RSI | ⭐ EDGE FOUND
CAT | 57.33% | Dist_SMA50 | ⭐⭐ HIGH SIGNAL
GOOGL | 53.42% | Vol_20D | ⭐ EDGE FOUND
MPWR | 57.33% | Vol_20D | ⭐⭐ HIGH SIGNAL
ALB | 52.44% | Vol_20D | ⭐ EDGE FOUND
GIS | 57.65% | Dist_SMA50 | ⭐⭐ HIGH SIGNAL
CVS | 56.68% | Dist_SMA50 | ⭐⭐ HIGH SIGNAL
FISV | 47.56% | RSI | ❌ TRAP
INTC | 51.79% | RSI | ⭐ EDGE FOUND
TTD | 43.00% | Dist_SMA50 | ❌ TRAP
CHTR | 41.37% | Vol_20D | ❌ TRAP
CPB | 40.39% | Vol_20D | ❌ TRAP
PCG | 48.53% | Vol_20D | ❌ TRAP
GDDY | 43.97% | Vol_20D | ❌ TRAP
HPQ | 46.25% | Dist_SMA50 | ❌ TRAP
KLAC | 55.70% | RSI | ⭐⭐ HIGH SIGNAL
CHRW | 51.47% | Dist_SMA50 | ⭐ EDGE FOUND
RL | 54.40% | Vol_20D | ⭐ EDGE FOUND
HAS | 54.40% | Dist_SMA50 | ⭐ EDGE FOUND
CMI | 51.79% | Vol_20D | ⭐ EDGE FOUND
IT | 37.13% | Vol_20D | ❌ TRAP
TYL | 47.56% | Vol_20D | ❌ TRAP
HII | 56.03% | Vol_20D | ⭐⭐ HIGH SIGNAL
DECK | 48.86% | Dist_SMA50 | ❌ TRAP
JNJ | 45.93% | RSI | ❌ TRAP
VRSK | 40.39% | Vol_20D | ❌ TRAP
DG | 52.12% | Vol_20D | ⭐ EDGE FOUND
WDC | 41.69% | Vol_20D | ❌ TRAP
GPN | 47.56% | Vol_20D | ❌ TRAP
GS | 58.63% | Dist_SMA50 | ⭐⭐ HIGH SIGNAL
--------------------------------------------------------------------------------
✅ AUDIT COMPLETE.
• Total Scanned: 67
• Predictable (>51%): 35
• Random/Noisy (49-51%): 8
================================================================================
I will now present a portfolio long-short that uses only those stock with a predictability score higher that 50%. Then run the optimisation to get the max Sharpe portfolio.
I don't care if this stock has great momentum. If the AI says its movement is random noise (Accuracy < 50%), I am not trading it.
This "Funnel" approach ensures that your final capital is only deployed into stocks that are both trending (Momentum) and predictable (ML Validation).
===============================================================================================
FINAL STEP: GENERATING THE ML-VERIFIED PORTFOLIOS (WITH PORTFOLIO STATS)
===============================================================================================
Applying Filter: Rejecting any stock with Predictability <= 50%...
🗑️ REJECTED (29): WDC, STX, MU, CVNA, GLW, GOOG, AMAT, F, JNJ, TTD...
✅ SURVIVORS: 32 Longs, 6 Shorts
... Re-calculating Optimal Weights for Survivors ...
===============================================================================================
🚀 FINAL EXECUTION LIST (ML-VERIFIED) 🚀
===============================================================================================
>> SMART LONG PORTFOLIO
📊 PORTFOLIO STATS: Exp Return: 78.6% | Volatility: 18.7% | Sharpe: 3.99
-----------------------------------------------------------------------------------------------
TICKER | WGT % | ML CONF | EXP RET | EXP VOL | CORR | STATUS
-----------------------------------------------------------------------------------------------
MNST | 29.3% | 55.0% | 52.1% | 22.6% | 0.28 | Trusted ✅
HII | 23.9% | 56.0% | 96.6% | 33.5% | 0.49 | Trusted ✅
DG | 17.9% | 52.1% | 71.7% | 37.0% | 0.08 | Trusted ✅
NEM | 12.7% | 58.0% | 104.5% | 41.0% | 0.37 | Trusted ✅
APH | 7.2% | 56.0% | 75.9% | 34.5% | 0.77 | Trusted ✅
LRCX | 2.9% | 50.8% | 102.6% | 50.3% | 0.82 | Trusted ✅
INTC | 2.9% | 51.8% | 99.6% | 68.4% | 0.51 | Trusted ✅
AMD | 1.6% | 52.1% | 95.3% | 59.9% | 0.67 | Trusted ✅
ALB | 0.9% | 52.4% | 100.8% | 61.3% | 0.57 | Trusted ✅
CHRW | 0.8% | 51.5% | 61.5% | 37.7% | 0.46 | Trusted ✅
-----------------------------------------------------------------------------------------------
>> SMART SHORT PORTFOLIO
📊 PORTFOLIO STATS: Exp Return: 44.6% | Volatility: 19.9% | Sharpe: 2.04
-----------------------------------------------------------------------------------------------
TICKER | WGT % | ML CONF | EXP RET | EXP VOL | CORR | STATUS
-----------------------------------------------------------------------------------------------
FDS | 34.4% | 53.1% | -51.4% | 29.3% | 0.69 | Trusted ✅
DVA | 27.6% | 51.8% | -49.1% | 31.2% | 0.61 | Trusted ✅
GIS | 19.9% | 57.7% | -28.5% | 23.3% | 0.44 | Trusted ✅
NOW | 12.1% | 50.2% | -42.9% | 39.6% | 0.64 | Trusted ✅
ERIE | 5.9% | 52.8% | -41.1% | 31.9% | 0.64 | Trusted ✅
-----------------------------------------------------------------------------------------------
💾 SAVED DETAILED REPORT: Final_Smart_Portfolio_FullMetrics_20260125_1721.csv
💡 INTERPRETATION: • PORTFOLIO STATS (Top of section) show the mathematical expectancy of the basket. • ASSET STATS show individual contribution. • Combining High Return assets with LOW CORRELATION reduces Portfolio Volatility.
================================================================================
REALITY CHECK: RECENT PERFORMANCE OF ML PICKS
================================================================================
⚙️ VERIFICATION WINDOW:
• Checking trend from: 2025-12-26
• To latest close: 2026-01-23
• Goal: Did the 'Survivors' actually outperform?
------------------------------------------------------------
STRATEGY | RETURN (21d) | ALPHA
------------------------------------------------------------
Strategy 1 (Smart Long) | +12.83% | ++13.02%
Strategy 2 (Smart Hedge) | +8.95% | ++9.14%
------------------------------------------------------------
Benchmark (S&P 500) | -0.19% | 0.00%
------------------------------------------------------------
>> BREAKDOWN: STRATEGY 1 (LONG ONLY) Goal: Price should go UP (+) --------------------------------------------------------------------------- TICKER | WEIGHT | PRICE MOVE | RESULT --------------------------------------------------------------------------- MNST | 29.27% | +6.13% | ✅ PROFIT HII | 23.92% | +19.28% | ✅ PROFIT DG | 17.85% | +7.10% | ✅ PROFIT NEM | 12.73% | +17.58% | ✅ PROFIT APH | 7.16% | +9.93% | ✅ PROFIT LRCX | 2.91% | +22.46% | ✅ PROFIT INTC | 2.86% | +24.57% | ✅ PROFIT AMD | 1.59% | +20.86% | ✅ PROFIT ALB | 0.89% | +26.40% | ✅ PROFIT CHRW | 0.82% | +7.37% | ✅ PROFIT --------------------------------------------------------------------------- >> BREAKDOWN: STRATEGY 2 (HEDGED) Goal: Longs UP (+), Shorts DOWN (-) --------------------------------------------------------------------------- TICKER | POSITION | WEIGHT | PRICE MOVE | RESULT --------------------------------------------------------------------------- FDS | SHORT | 17.18% | -1.81% | ✅ PROFIT MNST | LONG | 14.63% | +6.13% | ✅ PROFIT DVA | SHORT | 13.80% | -5.09% | ✅ PROFIT HII | LONG | 11.96% | +19.28% | ✅ PROFIT GIS | SHORT | 9.97% | -3.90% | ✅ PROFIT DG | LONG | 8.93% | +7.10% | ✅ PROFIT NEM | LONG | 6.36% | +17.58% | ✅ PROFIT NOW | SHORT | 6.06% | -13.45% | ✅ PROFIT APH | LONG | 3.58% | +9.93% | ✅ PROFIT ERIE | SHORT | 2.97% | -1.75% | ✅ PROFIT LRCX | LONG | 1.46% | +22.46% | ✅ PROFIT INTC | LONG | 1.43% | +24.57% | ✅ PROFIT AMD | LONG | 0.80% | +20.86% | ✅ PROFIT ALB | LONG | 0.44% | +26.40% | ✅ PROFIT CHRW | LONG | 0.41% | +7.37% | ✅ PROFIT ---------------------------------------------------------------------------
ML filtered stock portfolio - LONG ONLY STRATEGY¶
# PARAMETERS
# We use 252 days for Momentum (Standard) and 126 days (6 months) for Risk calculation
LOOKBACK_MOMENTUM = 252
LOOKBACK_RISK = 126
MAX_WEIGHT_PER_ASSET = 0.20 # Diversification Rule: Max 20% in one stock
RISK_FREE_RATE = last_rf # last Annual Risk-Free Rate
================================================================================
LONG ONLY PORTFOLIO: FROM SURVIVORS TO OPTIMIZED ALLOCATION
================================================================================
⚙️ BUILD PARAMETERS:
• Optimization Date: 2026-01-23
• Diversification: Max 20% per asset (Hard Cap)
• Objective: Maximize Sharpe Ratio (Risk-Adjusted Return)
📥 CANDIDATE SOURCE: ML-Verified Survivors (Block 17)
• Count: 32 Tickers
... Calculating covariance matrix for 32 assets ...
... Solving for Max Sharpe Ratio with Constraints ...
================================================================================
🏆 FINAL OPTIMIZED PORTFOLIO 🏆
================================================================================
PORTFOLIO METRICS (ANNUALIZED PREDICTION):
• Expected Return: 92.72%
• Risk (Vol): 12.91%
• Sharpe Ratio: 6.87
--------------------------------------------------------------------------------
TICKER | WEIGHT | SHARES (Approx £10k)
--------------------------------------------------------------------------------
MNST | 20.00% | 32.93 shares (£2000)
CVS | 17.18% | 27.95 shares (£1718)
GOOGL | 10.76% | 4.43 shares (£1076)
NEM | 8.33% | 9.05 shares (£833)
DG | 8.14% | 7.48 shares (£814)
STLD | 6.24% | 4.64 shares (£624)
CAH | 6.01% | 3.89 shares (£601)
ALB | 5.19% | 3.69 shares (£519)
HII | 4.21% | 1.36 shares (£421)
CMI | 3.75% | 0.89 shares (£375)
INTC | 3.68% | 11.02 shares (£368)
CHRW | 2.66% | 2.03 shares (£266)
LRCX | 1.93% | 1.2 shares (£193)
RTX | 1.92% | 1.32 shares (£192)
--------------------------------------------------------------------------------
TOTAL ALLOCATION: 100.00%
💾 SAVED TO CSV: Final_LongOnly_Portfolio_Optimized_20260125_1721.csv
Next block performs a "Deep Dive Risk Audit" on the portfolio just built.
It simulates holding the optimized portfolio over the last 12 months to calculate professional-grade risk metrics. This tells you why your portfolio made money:
Beta: Did it just ride the market wave?
Alpha: Did it actually beat the market through skill?
Treynor Ratio: Was the return worth the specific risk taken?
================================================================================
HISTORICAL AUDIT: DEEP DIVE RISK METRICS
================================================================================
📅 AUDIT PERIOD: 2025-01-23 -> 2026-01-23
• Portfolio: Optimized Diversified Model (14 Assets)
================================================================================
📊 ADVANCED PERFORMANCE REPORT (1 YEAR BACKTEST) 📊
================================================================================
METRIC | PORTFOLIO | BENCHMARK (SPY)
--------------------------------------------------------------------------------
Total Return | +76.25% | +14.32%
Annual Volatility | 17.16% | 18.94%
Max Drawdown | -9.18% | -18.76%
--------------------------------------------------------------------------------
Sharpe Ratio | 4.21 | 0.54
Treynor Measure | 1.14 | --
Jensen's Alpha | +65.74% | --
--------------------------------------------------------------------------------
Beta | 0.63 | 1.00
Correlation | 0.70 | 1.00
================================================================================
📝 METRIC DECODER:
🛡️ BETA (0.63): Your portfolio is LESS volatile than the S&P 500.
🔗 CORRELATION (0.70): 1.0 means you move exactly with the market.
(Lower is better for diversification/hedging).
Let's assume we bought this portfolio of stocks 4 trading weeks ago - THIS WILL HAVE A LOOK-AHEAD BIAS, HOWEVER WE CAN UNDERSTAND THE CORRELATION OF THIS PORTFOLIO
LONG-SHORT HEDGED 0 cost portfolio¶
===============================================================================================
🚀 FINAL PRODUCTION RUN: LONG-SHORT HEDGED ORDERS (METRICS INCLUDED) 🚀
===============================================================================================
⚙️ EXECUTION PARAMETERS:
• Analysis Date: 2026-01-23
• Strategy Type: Market Neutral (Long Winners / Short Losers)
• Optimization Target: Maximize Sharpe (Dollar Neutral)
• Constraints: Max 20% per position | Net Exposure = 0%
📥 CANDIDATE SOURCE: ML-Verified Survivors (Block 17)
• Available Longs: 32
• Available Shorts: 6
... Calculating Optimal Hedged Positions ...
===============================================================================================
🛒 OFFICIAL HEDGED ORDERS (VALID FOR 1 MONTH) 🛒
===============================================================================================
STRATEGY GOAL: Recession Proofing. Profit from Spread (Winners - Losers).
📊 PORTFOLIO STATS: Exp Spread (Alpha): 88.95% | Volatility: 14.36% | Sharpe: 6.20
-----------------------------------------------------------------------------------------------
TICKER | ALLOCATION | ACTION | SHARES | EXP RET | EXP VOL
-----------------------------------------------------------------------------------------------
MNST | 18.08% | BUY | 29.77 🟢 | 52.1% | 22.6%
STLD | 14.10% | BUY | 10.5 🟢 | 34.5% | 36.7%
CVS | 13.80% | BUY | 22.44 🟢 | 43.3% | 30.7%
IVZ | 11.01% | BUY | 52.34 🟢 | 43.8% | 39.7%
ALB | 5.98% | BUY | 4.26 🟢 | 100.8% | 61.3%
CAH | 4.94% | BUY | 3.2 🟢 | 46.7% | 27.3%
DG | 4.86% | BUY | 4.46 🟢 | 71.7% | 37.0%
EL | 3.49% | BUY | 4.0 🟢 | 65.1% | 45.7%
IDXX | 3.02% | BUY | 0.59 🟢 | 41.6% | 42.4%
GOOGL | 2.94% | BUY | 1.21 🟢 | 51.5% | 31.9%
CHRW | 2.89% | BUY | 2.21 🟢 | 61.5% | 37.7%
INTC | 2.85% | BUY | 8.54 🟢 | 99.6% | 68.4%
COR | 2.57% | BUY | 0.98 🟢 | 31.7% | 21.9%
HII | 2.43% | BUY | 0.78 🟢 | 96.6% | 33.5%
NEM | 1.61% | BUY | 1.75 🟢 | 104.5% | 41.0%
FDS | 5.21% | SELL | 2.45 🔴 | -51.4% | 29.3%
ERIE | 11.13% | SELL | 5.45 🔴 | -41.1% | 31.9%
GIS | 19.03% | SELL | 57.66 🔴 | -28.5% | 23.3%
NOW | 19.18% | SELL | 19.45 🔴 | -42.9% | 39.6%
PYPL | 20.00% | SELL | 47.69 🔴 | -34.1% | 34.7%
DVA | 20.00% | SELL | 24.97 🔴 | -49.1% | 31.2%
-----------------------------------------------------------------------------------------------
💾 SAVED HEDGED ORDERS TO: ML_TRUSTED_STOCKS_Hedged_Portfolio_20260125_1721.csv
LET'S LOOK HOW THIS PORTFOLIO HAS PERFORMED LAST MONTH THEN.
1-YEAR HISTORICAL AUDIT (MARKET NEUTRAL EDITION)¶
================================================================================
LONG-SHORT PORTFOLIO: HEDGE FUND RISK METRICS
================================================================================
📅 AUDIT PERIOD: 2025-01-23 -> 2026-01-23
• Portfolio: Long-Short Market Neutral (21 Positions)
================================================================================
📊 HEDGE FUND PERFORMANCE REPORT (1 YEAR) 📊
================================================================================
METRIC | HEDGED PORTFOLIO | S&P 500 (BENCHMARK)
--------------------------------------------------------------------------------
Total Return | +155.16% | +14.32%
Annual Volatility | 14.68% | 18.94%
Max Drawdown | -3.33% | -18.76%
--------------------------------------------------------------------------------
Sharpe Ratio | 10.30 | 0.54
Jensen's Alpha | +150.23% | --
--------------------------------------------------------------------------------
Beta | 0.09 | 1.00
Correlation | 0.12 | 1.00
================================================================================
📝 METRIC DECODER (MARKET NEUTRAL EDITION):
✅ BETA (0.09): SUCCESS. Your portfolio is 'Uncorrelated'.
It ignores market crashes and moves based on your stock picks.
In a normal "Buy and Hold" portfolio, return comes from the sensitivity (beta) of the portfolio to overall market direction.
But now I'll forced the portfolio's Beta to be 0.00. The alghoritm will use weights and the security's betas to achieve a portfolio that is uncorrelated with the overall market.
Therefore, the only way for the porfolio to make money is having the right stock picks, no matter the direction of the market.
In finance, return that is generated purely from skill/stock-picking (independent of the market) is defined as Alpha.
BETA-NEUTRAL HEDGE portfolio¶
================================================================================
🚀 FINAL PRODUCTION RUN: TRUE BETA-NEUTRAL HEDGING 🚀
================================================================================
⚙️ EXECUTION PARAMETERS:
• Analysis Date: 2026-01-23
• Strategy Type: BETA NEUTRAL
• Optimization Target: Maximize Sharpe
• Constraint: Sum(Weight * Beta) = 0.0
📥 CANDIDATE SOURCE: ML-Verified Survivors (Block 17)
• Available Longs: 32
• Available Shorts: 6
... Calculating Stock Betas vs S&P 500 ...
• Beta Range: -0.49 to 2.75
... Optimizing for Zero Beta Exposure ...
================================================================================
🛒 OFFICIAL BETA-NEUTRAL ORDERS (VALID FOR 1 MONTH) 🛒
================================================================================
STRATEGY: Risk-Balanced Hedge. If Market Crashes, Beta Exposure ~ 0.
--------------------------------------------------------------------------------
TICKER | BETA | ALLOCATION | ACTION | SHARES (£10k)
--------------------------------------------------------------------------------
MNST | -0.20 | 20.00% | BUY | 32.93 shs 🟢
CVS | 0.14 | 19.17% | BUY | 31.19 shs 🟢
STLD | 1.20 | 11.79% | BUY | 8.78 shs 🟢
COR | -0.13 | 10.92% | BUY | 4.17 shs 🟢
IVZ | 1.66 | 7.51% | BUY | 35.72 shs 🟢
CAH | -0.34 | 4.81% | BUY | 3.12 shs 🟢
DG | 0.45 | 4.79% | BUY | 4.4 shs 🟢
ALB | 1.43 | 4.26% | BUY | 3.03 shs 🟢
EL | 1.27 | 3.07% | BUY | 3.52 shs 🟢
NEM | 0.75 | 3.01% | BUY | 3.27 shs 🟢
CHRW | 0.39 | 2.83% | BUY | 2.16 shs 🟢
INTC | 1.90 | 2.02% | BUY | 6.05 shs 🟢
RTX | 0.61 | 1.53% | BUY | 1.05 shs 🟢
IDXX | 1.67 | 0.52% | BUY | 0.1 shs 🟢
GOOGL | 1.35 | 0.42% | BUY | 0.17 shs 🟢
ERIE | -0.26 | 3.56% | SELL | 1.74 shs 🔴
FDS | 0.27 | 4.04% | SELL | 1.9 shs 🔴
NOW | 0.82 | 9.97% | SELL | 10.11 shs 🔴
PYPL | 1.45 | 20.00% | SELL | 47.69 shs 🔴
DVA | 0.33 | 20.00% | SELL | 24.97 shs 🔴
--------------------------------------------------------------------------------
✅ NET BETA EXPOSURE: 0.0000 (Target: 0.0000)
ℹ️ NET DOLLAR EXPOSURE: 39.09% (May not be zero!)
--------------------------------------------------------------------------------
💾 SAVED BETA-NEUTRAL ORDERS TO: ML_TRUSTED_STOCKS_BetaNeutral_Portfolio_20260125_1721.csv
1-YEAR HISTORICAL AUDIT (MARKET NEUTRAL EDITION)¶
================================================================================
AUDIT: BETA-NEUTRAL PORTFOLIO RISK METRICS
================================================================================
📅 AUDIT PERIOD: 2025-01-23 -> 2026-01-23
• Portfolio: Beta-Neutral Hedge (20 Positions)
================================================================================
📊 BETA-NEUTRAL PERFORMANCE REPORT (1 YEAR) 📊
================================================================================
METRIC | BETA-NEUTRAL PORTFOLIO | S&P 500
--------------------------------------------------------------------------------
Total Return | +119.44% | +14.32%
Annual Volatility | 12.46% | 18.94%
Max Drawdown | -3.65% | -18.76%
--------------------------------------------------------------------------------
Sharpe Ratio | 9.26 | 0.54
Jensen's Alpha | +114.59% | --
--------------------------------------------------------------------------------
Beta | 0.0824 | 1.00
Correlation | 0.13 | 1.00
================================================================================
📝 METRIC DECODER (BETA NEUTRAL):
🏆 BETA (0.0824): PERFECT. You have achieved True Market Neutrality.
Your returns are now purely based on Stock Selection skill (Alpha).
SINGLE INDEX MODEL (SIM): SEPARATING SKILL (ALPHA) FROM LUCK (BETA)¶
===============================================================================================
LABORATORY: COMPARING 3 PORTFOLIO ARCHITECTURES (GBP BASE)
===============================================================================================
✅ Loaded Survivors: 32 Longs, 6 Shorts
... Constructing S&P 500 (GBP) Benchmark ...
... Calculating Asset Betas (GBP Basis) ...
... Building Strategy A: Long Only ...
... Building Strategy B: Dollar Neutral (Cash Balanced) ...
... Building Strategy C: Beta Neutral (Risk Balanced) ...
-----------------------------------------------------------------------------------------------
REGRESSION RESULTS (1 YEAR LOOKBACK)
-----------------------------------------------------------------------------------------------
STRATEGY | BETA | ALPHA (Ann) | R-SQUARED | VERDICT
-----------------------------------------------------------------------------------------------
Long Only | 0.66 | 56.67% | 0.56 | Market Risk
Dollar Neutral | 0.04 | 91.93% | 0.00 | True Hedge ✅
Beta Neutral | 0.00 | 92.21% | 0.00 | True Hedge ✅
-----------------------------------------------------------------------------------------------
💡 KEY TAKEAWAY: • Long Only: Should have Beta ~1.0 and High R-Squared (Moves with market). • Dollar Neutral: Beta usually > 0 because winners (Longs) often have higher beta than losers (Shorts). • Beta Neutral: Should have Beta ~ 0.0 and R-Squared ~ 0.0 (True Alpha).
##################################################################################################################################################################################
This block is the Efficiency Scorecard.¶
It tells you if you are squeezing all the juice out of your stock picks, or if you are leaving profit on the table for the sake of safety. A sharpe ratio higher than the THEORETICAL portfolio would mean that the startegy 1 - 2 delivers more risk premium for unit of risk, on the other hand a lower Sharpe ratio would indicate that a more efficient portfolio exist (the reason could be that the weight constrains play a role in this of course - but I think diversification in securities selection is important too).
In other words, it calculates the "Cost of Safety." If the Theoretical Sharpe is 5.0 and your Real Sharpe is 4.8, your safety rules are efficient. If Theoretical is 5.0 and Real is 2.0, your safety rules are too strict and choking your profits.
================================================================================
PORTFOLIO COMPOSITION & EFFICIENT FRONTIER CHECK
================================================================================
>>> STRATEGY 1: ML-ENHANCED (LONG ONLY)
------------------------------------------------------------
Expected Return: 89.09%
Annual Risk: 14.24%
Sharpe Ratio: 5.98
------------------------------------------------------------
Weight
MNST 20.00%
CVS 17.18%
GOOGL 10.76%
NEM 8.33%
DG 8.14%
STLD 6.24%
CAH 6.01%
ALB 5.19%
HII 4.21%
CMI 3.75%
------------------------------------------------------------
>>> STRATEGY 2: ML-HEDGED (MARKET NEUTRAL)
------------------------------------------------------------
Expected Return: 109.76%
Annual Risk: 12.20%
Sharpe Ratio: 8.67
------------------------------------------------------------
Weight
MNST 20.00%
CVS 19.17%
STLD 11.79%
COR 10.92%
IVZ 7.51%
CAH 4.81%
DG 4.79%
ALB 4.26%
EL 3.07%
NEM 3.01%
------------------------------------------------------------
>>> CALCULATING THEORETICAL MAXIMUM SHARPE (UNCONSTRAINED)...
>>> STRATEGY 3: THEORETICAL MAX SHARPE (BENCHMARK)
------------------------------------------------------------
Expected Return: 135.24%
Annual Risk: 17.00%
Sharpe Ratio: 7.72
------------------------------------------------------------
Weight
MNST 29.03%
DG 19.83%
HII 14.25%
ALB 13.25%
CMI 11.95%
NEM 7.24%
CAH 4.46%
------------------------------------------------------------
💡 INSIGHT: THE COST OF CONSTRAINTS The Red Star (*) is the mathematical maximum return for the risk. The Green Circle is your Real World portfolio. • If they are close: Your constraints (20% cap) are efficient. • If Green is far below Red: Your constraints are costing you significant return.
================================================================================
PORTFOLIO REPORT CARD: REALITY VS. MATH PERFECTION
================================================================================
... Calculating Theoretical Maximum Efficiency ...
--------------------------------------------------------------------------------
🔎 AUDIT: STRATEGY 1 (SMART LONG)
--------------------------------------------------------------------------------
METRIC | YOUR STRATEGY | THEORETICAL MAX | EFFICIENCY
--------------------------------------------------------------------------------
Annual Return | 89.09% | 135.24% | 65.9%
Sharpe Ratio | 5.98 | 7.72 | 77.4%
--------------------------------------------------------------------------------
✅ VERDICT: GOOD. A healthy balance of safety and performance.
-------------------------------------------------------------------------------- 🔎 AUDIT: STRATEGY 2 (SMART HEDGE) -------------------------------------------------------------------------------- METRIC | YOUR STRATEGY | THEORETICAL MAX | EFFICIENCY -------------------------------------------------------------------------------- Annual Return | 109.76% | 135.24% | 81.2% Sharpe Ratio | 8.67 | 7.72 | 112.4% -------------------------------------------------------------------------------- ✅ VERDICT: ELITE. Your safety rules are barely costing you any performance.
================================================================================
🎓 CONCEPT: THE EFFICIENCY SCORE
================================================================================
This score measures the 'Cost of Safety' in your portfolio.
1️⃣ THEORETICAL MAX (The Robot):
The computer finds the mathematically perfect portfolio. It ignores risk
concentration. It might put 80% of your money into one volatile stock
if the numbers look good. This has the highest possible Sharpe Ratio.
2️⃣ YOUR STRATEGY (The Human):
You have added safety rules: 'Max 20% per stock', 'Long Only', etc.
These rules protect you from ruin, but they lower your theoretical score.
📊 HOW TO READ YOUR SCORE:
• 90%+ : ELITE. You bought safety very cheaply. You are protected
but still capturing almost all the upside.
• 50% : EXPENSIVE. Your safety rules are too strict. You are forcing
diversification into bad stocks just to fill a quota.
================================================================================
================================================================================
STRESS TEST: PROBABILISTIC RISK FORECAST (ZOOMED)
================================================================================
⚙️ Simulation Config: 5000 Paths over 1 Year.
Scenario: Returns x0.5, Volatility x1.5
--------------------------------------------------------------------------------
STRATEGY | STRESS VOL | SURVIVAL (VaR 95%)
--------------------------------------------------------------------------------
Strategy 1 (Smart Long) | Risk (Vol): 21.4% | Worst Case (95%): £10,810
Strategy 2 (Smart Hedge) | Risk (Vol): 18.3% | Worst Case (95%): £12,629
Theoretical Max | Risk (Vol): 25.5% | Worst Case (95%): £12,571
--------------------------------------------------------------------------------
💡 HOW TO READ THIS CHART: 1. SHADED CONES: Represent 5,000 possible futures. The darker area is the 'Likely' outcome. 2. DOTTED LINES: The 'Worst Case Scenario' (Bottom 5%). If this line stays above £0, you survive. 3. ZOOM: We cropped the top lucky outliers to focus on DOWNSIDE PROTECTION.
================================================================================
ALLOCATION LAB: FINDING THE GOLDEN RATIO & CAL
================================================================================
📊 INPUTS (Data-Driven from Last 6 Months):
> Strategy 1 (Smart Long) | Risk: 12.8% | Est. Return: 15.0%
> Strategy 2 (Smart Hedge) | Risk: 11.5% | Est. Return: 8.0%
> Correlation Coefficient: 0.60
================================================================================
🏆 FINAL RECOMMENDATION: THE GOLDEN RATIO 🏆
================================================================================
The Tangency Portfolio (Gold Star) is the mathematical optimum.
--------------------------------------------------------------------------------
OPTIMAL RISKY MIX:
👉 100% to Strategy 1 (Long Only)
👉 0% to Strategy 2 (Market Neutral)
--------------------------------------------------------------------------------
PORTFOLIO STATS:
• Expected Return: 15.0%
• Expected Volatility: 12.8%
• Sharpe Ratio: 0.86
--------------------------------------------------------------------------------
💡 HOW TO USE THE CAL:
• If you want LESS risk: Move down the Blue Dotted Line (Hold some Cash).
• If you want MORE risk: Move up the Blue Dotted Line (Use Leverage).
• NEVER move off the line (e.g., don't just buy Strategy 1 alone).
It is always mathematically superior to hold the Tangency Mix +/- Cash.
#####################################################################################################################################
STRESS TEST: COVID CRASH & RECOVERY (FEB - AUG 2020)¶
================================================================================
STRESS TEST: COVID CRASH & RECOVERY (FEB - AUG 2020)
================================================================================
Simulating 23 assets over the Covid Crisis...
Period: 2020-02-01 to 2020-08-01
================================================================================
CRASH TEST REPORT CARD
================================================================================
STRATEGY | MAX DRAWDOWN | RECOVERY (Return)
--------------------------------------------------------------------------------
S&P 500 (Benchmark) | -33.92% | +0.68%
Strategy 1 (Smart Growth) | -28.09% | +9.53%
Strategy 2 (Smart Hedge) | -18.27% | -11.16%
--------------------------------------------------------------------------------
================================================================================
FINAL SAFETY AUDIT
================================================================================
Strategy: Strategy 1 (Smart Growth)
• Top 5 Concentration: 64.4%
• Crash Resistance: -28.1% (vs Mkt -33.9%)
👉 VERDICT: ℹ️ MATCHES Market Risk, ⚠️ HIGH Concentration
----------------------------------------
Strategy: Strategy 2 (Smart Hedge)
• Top 5 Concentration: 91.0%
• Crash Resistance: -18.3% (vs Mkt -33.9%)
👉 VERDICT: ✅ SAFER than Market, ⚠️ HIGH Concentration
----------------------------------------
Event Study — a classic quantitative method to measure Post-Earnings Announcement Drift (PEAD).¶
This answers a critical trading question:
"When my stocks beat earnings, does the price jump once and stop?" (Efficient Market)
"Or does it keep drifting up for weeks?" (PEAD - Profitable)
As noted by Bernard and Thomas (1989), Ball and Brown (1968) were the first to observe that even after earnings announcements, estimated cumulative abnormal returns continue to drift upward for good news firms and downward for bad news firms. Competing explanations for post-earnings-announcement drift (PEAD) fall into two categories. One class posits that at least part of the price response to new information is delayed; a second suggests that the capital asset pricing model (CAPM) used to calculate abnormal returns is either incomplete or misestimated, so researchers fail to fully adjust raw returns for risk. Can we then take advantage of this recurring event in the market to make a consistent profit? The following block will show the effect of earnings announcement with consequent POSITIVE or NEGATIVE SURPRICE on securities. I have analysed both the SHORT TERM EFFECT and the MEDIUM TERM EFFECT.
Bernard, V.L. and Thomas, J.K. (1989). Post-Earnings-Announcement Drift: Delayed Price Response or Risk Premium? Journal of Accounting Research, 27, pp.1–36. doi:https://doi.org/10.2307/2491062.
- How This Code Works (The Event Study): It uses an Event Study Methodology. It takes every earnings date for every S&P 500 stock over the last 2 years and aligns them all to "Day 0."
Day 0: The day earnings are released.
Day -10 to +10: Short-term reaction (The "Pop").
Day -63 to +63: Medium-term trend (The "Drift").
If the "Positive Surprise" green line keeps going up after Day 0, PEAD exists, and you should hold your winners. If it goes flat, the market is efficient, and you should take profits quickly.
================================================================================
MARKET RESEARCH: EARNINGS DRIFT ON S&P 500 (SHORT vs QUARTERLY)
================================================================================
✅ Loaded Clean S&P 500 List: 503 Stocks
🔎 Analyzing Earnings Reactions for 503 Stocks...
... Downloading Benchmark (SPY) Data ...
--------------------------------------------------------------------------------
PROGRESS | TICKER | STATUS | EVENTS
--------------------------------------------------------------------------------
25/503 | AEE | ✅ Processed | 11
50/503 | ATO | ✅ Processed | 11
75/503 | BR | ✅ Processed | 11
100/503 | CHTR | ✅ Processed | 11
125/503 | COO | ✅ Processed | 11
150/503 | FANG | ✅ Processed | 11
175/503 | EQT | ✅ Processed | 12
200/503 | FE | ✅ Processed | 11
225/503 | HAL | ✅ Processed | 12
250/503 | IR | ✅ Processed | 11
275/503 | KIM | ✅ Processed | 11
300/503 | MRSH | ✅ Processed | 12
325/503 | MS | ✅ Processed | 12
350/503 | ODFL | ✅ Processed | 11
375/503 | PPL | ✅ Processed | 11
400/503 | ROK | ✅ Processed | 11
425/503 | STLD | ✅ Processed | 12
450/503 | TT | ✅ Processed | 11
475/503 | VICI | ✅ Processed | 11
500/503 | YUM | ✅ Processed | 11
503/503 | ZTS | ✅ Processed | 11
--------------------------------------------------------------------------------
Total Events Analyzed: 5527
============================================================
SHORT TERM STATS (10 DAYS) - S&P 500
============================================================
METRIC | WINNERS (Beats) | LOSERS (Misses)
------------------------------------------------------------
Initial Pop (Day 0) | +1.16% | -2.43%
Post-Event Drift | -0.33% | -0.20%
Total 10-Day Return | +0.83% | -2.62%
⚠️ INSIGHT: The Market is EFFICIENT. Gains happen instantly. Don't chase.
============================================================
MEDIUM TERM STATS (3 MONTHS) - S&P 500
============================================================
METRIC | WINNERS | LOSERS
------------------------------------------------------------
Total 3-Mo Return | -1.55% | -2.60%
------------------------------------------------------------
⚠️ INSIGHT: Earnings beats are short-lived. The market Mean Reverts.
Let's now see the strategy in action. We buy those stocks that have a earning surprise bigger than 2%, we hold them for 10 days then sell. Each trade size is £100.
================================================================================
STRATEGY OVERLAY: EARNINGS MOMENTUM BACKTEST (FULL MARKET)
================================================================================
📥 Source: Block 2 (S&P 500 Scrape)
🔎 Simulating Trades on 503 Assets (2023-Present)...
(This may take a moment due to data volume)
... Processed 50/503 tickers ...
... Processed 100/503 tickers ...
... Processed 150/503 tickers ...
... Processed 200/503 tickers ...
... Processed 250/503 tickers ...
... Processed 300/503 tickers ...
... Processed 350/503 tickers ...
... Processed 400/503 tickers ...
... Processed 450/503 tickers ...
... Processed 500/503 tickers ...
================================================================================
📊 MARKET-WIDE STRATEGY REPORT 📊
================================================================================
Total Trades: 3582
Win Rate: 53.5%
Avg Return per Trade: +0.53% <-- EDGE VERIFICATION
Median Return: +0.49%
Total Profit (on £100): £1898.45
--------------------------------------------------------------------------------
🏆 HALL OF FAME (Top 5 Wins): Ticker Type Date Surprise ROI_Pct PnL SMCI LONG 2024-01-30 0.076923 0.446119 44.611935 APP LONG 2024-11-07 0.344086 0.383652 38.365213 PLTR LONG 2023-05-09 0.250000 0.370933 37.093275 ERIE LONG 2023-07-28 0.193717 0.341849 34.184922 PLTR LONG 2024-11-05 0.500000 0.315921 31.592141
Post-earnings announcement drift (PEAD), also called post-earnings momentum, captures a market anomaly where stocks drift in the direction of an earnings surprise for weeks or months after the announcement. A win rate that exceeds the 50% mark over sufficient trades indicates a statistical edge, potentially profitable with favorable risk-reward ratios despite occasional losses. High-frequency trading (HFT) firms exploit this effectively due to rapid execution, while manual traders face challenges from holding periods and transaction costs.
############################################################################################################################## This project represents my own analysis and any portfolio may represent an investment recommendation. Where standard algorithms or code snippets from public documentation (e.g., Pandas documentation, StackOverflow) were used, they have been adapted to fit this specific dataset.
2026 PIERPAOLO MIRIZI. ALL RIGHT RESERVED